from django.shortcuts import render
from django.http import HttpResponse
from app1.one import Trade
import pandas as pd
import numpy as np
from pyecharts import *


# Create your views here.
REMOTE_HOST= "https://pyecharts.github.io/assets/js"


# 全部金额,销售最多的商品,销售金额最多的商品,产品“Chicken Bowl”,选择最多的配料
def index(request):
    chipo = Trade()
    all = chipo.all_money()
    most = chipo.most_commodity()
    money_most = chipo.most_money_commodity()
    chicken = chipo.chicken_bowl_most()
    context = {'all': all, 'most': most, 'money_most': money_most, 'chicken': chicken}
    return render(request, 'index.html', context)

# 每种商品的销售个数
def index1(request):
    chipo =Trade()
    bar = chipo.everyone_sales_num()
    context = dict(
        myechart=bar.render_embed(),
        host=REMOTE_HOST,
        script_list=bar.get_js_dependencies()
    )
    return render(request, 'index.html', context)

# 每种商品的销售金额
def index2(request):
    chipo =Trade()
    bar = chipo.everyone_money_commodity()
    context = dict(
        myechart=bar.render_embed(),
        host=REMOTE_HOST,
        script_list=bar.get_js_dependencies()
    )
    return render(request, 'index.html', context)

# 餐厅的产品的种类及对应的商品配料的价格
def index3(request):
    chipo =Trade()
    bar = chipo.everyone_money_commodity_dosing()
    context = dict(
        myechart=bar.render_embed(),
        host=REMOTE_HOST,
        script_list=bar.get_js_dependencies()
    )
    return render(request, 'index.html', context)

# 每种商品销售金额在流水总额中所占的比例
def index4(request):
    chipo = Trade()
    bar = chipo.everyone_money_to_all_money()
    context = dict(
        myechart=bar.render_embed(),
        host=REMOTE_HOST,
        script_list=bar.get_js_dependencies()
    )
    return render(request, 'index.html', context)

# 定单金额
def index5(request):
    chipo = Trade()
    bar = chipo.everyone__order_form_money()
    context = dict(
        myechart=bar.render_embed(),
        host=REMOTE_HOST,
        script_list=bar.get_js_dependencies()
    )
    return render(request, 'index.html', context)

# 产品“Chicken Bowl”每种配料选择的次数，及所占比例
def index6(request):
    chipo = Trade()
    bar = chipo.chicken_bowl()
    context = dict(
        myechart=bar.render_embed(),
        host=REMOTE_HOST,
        script_list=bar.get_js_dependencies()
    )
    return render(request, 'index.html', context)


